package com.nicy.angel.biz;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.HandlerMapping;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "用户控制器")
@Slf4j
@RestController
public class UserController {


    @Value("${user.names}")
    private String username;
    @Value("${pass.word}")
    private String password;


    @RequestMapping(path = "user",method = RequestMethod.GET)
    public String getUser(){
        return "账户:"+username+" 密码:"+password;
    }

    @ApiOperation(value = "hello方法")
    @RequestMapping(path = "hi/{name}",method = RequestMethod.DELETE)
    public String hello(@PathVariable("name") String name){
        return name;
    }

    private AntPathMatcher antPathMatcher = new AntPathMatcher();

//    @ApiOperation(value = "hello方法")
//    @RequestMapping(path = "hi/**",method = RequestMethod.GET)
//    public String hello(HttpServletRequest request){
//      `  String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
//        String matchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
//        return antPathMatcher.extractPathWithinPattern(matchPattern,path);
//    }

}
